package com.mimiwang.chat.service;

import com.mimiwang.chat.entity.Talk;
import com.mimiwang.chat.entity.TalkNoticeVo;

import java.util.List;

/**
 * @AUTHOR:游李滨
 * @DATE:2022/10/11 19:59
 */
public interface ChatTalkRedisService {

    /**
     *  获取存储redis时 key
     *  返回值： 配置前缀:senderId:receiverId:日期毫秒值
     * */
    String  getRedisStoreTalkKey(long senderId,long receiverId);
    /**
     *
     *  获取 【模糊查询】key
     *  功能：用于获取其他人发给接收者receiver的所有talk
     *  返回值:    配置前缀+":*:"+receiverId+":*";
     * */
    String  getRedisReceiverTalkKey(long receiverId);

    /**
     *
     *  获取 【模糊查询】key
     *  功能：用于获取发送者sender发送给其他人的所有talk
     *  返回值:    配置前缀+":"+senderId+":*:*";
     * */
    String  getRedisSenderTalkKey(int senderId);

    /**
     *
     * 将会话加入redis
     *
     * */
    int insertTalkToRedis(Talk talk);

    /**
     *  redis查询指定接收者id的所有会话
     *
     *
     * */
    List<TalkNoticeVo> selectReceiverTalk(int receiverId);
    /**
     *  redis查询指定发送者id的所有会话
     *
     *
     * */
    List<TalkNoticeVo> selectSenderTalk(int senderId);

    int deleteTalk(String key);
    int deleteTalkByReceiverId(long receiverId);
    int deleteTalk(List<String> keys);

}
